package model

import (
	"food-mgr/food-service/configs"
	"gorm.io/gorm"
)

type Shop struct {
	gorm.Model
	Name   string  `gorm:"type:varchar(30);comment:商品名称"`
	Price  float64 `gorm:"type:decimal(10,2);comment:商品价格"`
	Num    int     `gorm:"type:int(11);comment:商品库存"`
	Status string  `gorm:"type:varchar(30);comment:商品状态"`
	Count  int     `gorm:"type:int(11);comment:销量"`
}

func FindShop(s *Shop, id int) {
	configs.DB.Where("id=?", id).First(&s)
}
func ListShop(s *[]Shop) error {

	return configs.DB.Order("count DESC").Find(&s).Error
}
func UpdateShop(s *Shop, id int) {
	configs.DB.Where("id=?", id).Updates(&s)
}
